package ge.modules.drawables;

import ge.engine.Log;
import ge.engine.PositionableArea;
import ge.exceptions.FunctionNonSuported;
import ge.lowlevel.DrawEngine;

public class SquareModule extends DrawableObject implements PositionableArea {

 
	private Color color;
	 
	/**
	 * 	Draw a square (default color is black) in the screen
	 * @param width
	 * @param height
	 */
	public SquareModule(double width, double height)
	{
		super(width, height);
		color = new  Color();
	}
	 
	 
	public double getWidth() {
		return imageSquare.getWidth();
	}
	public double getHeight() {
		return imageSquare.getHeight();
	}
	/**
	 * @param c Color to be drown
	 */
	public void setColor(Color c)
	{
		color = c;
	}
	/**
	 * @return Actually square color
	 */
	public Color getColor()
	{
		return color;
	}
 

	@Override
	public void draw() 
	{
		try 
		{
			if(!isVisible())
				return;
			if(!isInsideScreen())
				return;
			DrawEngine.get().setLayer(layer);
			
			if(!color.isBlack())
					DrawEngine.get().setColor(color.getR(), color.getG(), color.getB(), color.getA());
			DrawEngine.get().drawRectangle(getRelativeX(), getRelativeY(), imageSquare.getWidth(), imageSquare.getHeight());
 
			if(!color.isBlack())
				DrawEngine.get().setColor(0,0,0);
		}
		catch (FunctionNonSuported e) 
		{
			e.printStackTrace();
		}
	}

	/**
	 *  Modify the area of the rectangle
	 *  @param width Width
	 *  @param Height Height
	 */
	@Override
	public void setArea(double width, double height) {
		 imageSquare.setArea(width, height);
		
	}

}
